
package br.com.solutions.delivery.controller;

import br.com.solutions.delivery.screen.MenuScreen;
import br.com.solutions.delivery.screen.TravelMenuScreen;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.logging.Level;
import java.util.logging.Logger;

public class MenuScreenControler {
    
    private MenuScreen form;
    
    private static MenuScreenControler instance;
    
    private static class CadastroCidadesListener implements ActionListener {
        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                CityScreenController.getInstance().showScreen();
            } catch (Exception ex) {
                Logger.getLogger(MenuScreenControler.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }
    
    private static class GerenciaViagensListener implements ActionListener {
        @Override
        public void actionPerformed(ActionEvent e) {
            TravelMenuScreenController.getInstance().showScreen();
        }
    }

        
    private MenuScreenControler(){
        this.form = MenuScreen.getInstance();
        this.form.getCadastroCidadesButton().addActionListener(new CadastroCidadesListener());
        this.form.getGerenciaViagensButton().addActionListener(new GerenciaViagensListener());
    }
    
    public static MenuScreenControler getInstance(){
        if (instance == null){
            instance = new MenuScreenControler();
        }
        return instance;
    }
    
    public void showScreen(){
        this.form.setVisible(true);
    }
    
    
    
    
    
}
